---
title: Creating triggers
---

# **Guide to Contributing Triggers in Blok **
<Tip> Make sure you follow the recommendations on how to set up local environment and steps to complete before committing your changes. To learn more [visit](/docs/c/overview/how-to-contribute)</Tip>

Triggers in `Blok` allow workflows to be executed **automatically** in response to specific events. This guide provides an overview of how to create, test, and contribute new triggers to the framework.

---

## **What Are Triggers?**  
Triggers define **when and how a workflow starts**. They listen for external or internal events, such as:  
- **HTTP Requests** (e.g., API calls) <Icon icon="check" iconType="solid" />  
- **Scheduled Events** (e.g., cron jobs)  
- **Database Changes** (e.g., new records in Postgres)  
- **Queue Messages** (e.g., Kafka, RabbitMQ events)  
- **Custom Events** (e.g., user-defined triggers)  

Triggers are stored in the `/triggers` directory and are configurable via CLI.

---

## **Getting Started**

Clone the repository and navigate to the `triggers` directory:  
```bash
git clone https://github.com/deskree-inc/blok.git
cd triggers
npm install
```

---

## **Adding a New Trigger**
1. Create a new directory in `/triggers`  
2. Use `http-trigger` as a template or build your own
3. Make sure you are using the [TriggerBase class](/docs/ref/runner/src/classes/TriggerBase) as the base class
4. Document your code, create interface definitions, and make sure you follow ESlint rules
5. Make sure you have tests for your trigger and you achieve full coverage after running `pnpm test`

---

## **Submitting a Pull Request**
1. **Follow Branch Naming Convention**  
   ```bash
   git checkout -b feature/add-my-new-trigger
   ```
2. **Ensure Code Quality**  
   ```bash
   npm run lint
   npm test
   ```
3. **Submit a PR** with:  
   - A **clear description** of the trigger.  
   - Tests and configuration examples.  
   - Proper **documentation** updates.  

---

## **Best Practices**
✅ **Keep triggers modular and lightweight.**  
✅ **Ensure proper error handling and logging.**  
✅ **Write clear documentation and tests.**  
✅ **Follow the project's TypeScript style guide.**  

---

## **Final Notes**
Triggers are a **key part of automation in Blok**. By contributing new triggers, you help expand the framework’s capabilities and enable more use cases. If you have any questions, open an issue or join the discussion! 🚀  
```